Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented Aug 21, 2025

Problem

When writing a subquery under a conditional directive, the indentation was less than expected. This was due to not properly considering the parent-child relationship of conditional directives.

Solution

This fix ensures that when a block immediately follows a conditional directive and is not the directive itself, the indentation calculation also takes into account the text length of the parent block of the conditional directive. This results in correct indentation for subqueries under conditional directives.

@xterao xterao self-assigned this Aug 21, 2025
@github-actions github-actions bot added the fix Bug fixes label Aug 21, 2025
@xterao
Copy link
Collaborator Author

xterao commented Aug 21, 2025

Merge after #404

@xterao xterao linked an issue Aug 21, 2025 that may be closed by this pull request
@xterao xterao added this to the 2.1.2 Release milestone Aug 21, 2025
@xterao xterao requested a review from Copilot August 21, 2025 01:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes subquery formatting under conditional directives by improving indentation calculation to properly consider parent-child relationships between conditional directives and subsequent blocks.

  • Updates conditional directive handling to calculate proper indentation for blocks following directives
  • Refactors keyword group block organization by moving option-related blocks to a dedicated package
  • Adds comprehensive test coverage for various conditional directive scenarios

Reviewed Changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
SqlElConditionLoopCommentBlock.kt Core logic changes for conditional directive indentation calculation
SqlSubQueryGroupBlock.kt Updates subquery indentation logic for conditional directive context
SqlBlockGenerator.kt Adds support for new IN and WHERE group blocks
SqlInGroupBlock.kt New block type for handling IN keyword formatting
SqlWhereGroupBlock.kt New block type for WHERE clause formatting
Package refactoring files Moves option keyword blocks to dedicated package structure
Test files Comprehensive test data for conditional directive formatting scenarios

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@xterao xterao merged commit e91b3ac into fix/sql-formatter Aug 21, 2025
5 checks passed
@xterao xterao deleted the fix/sql-format-sub-query-line branch August 21, 2025 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misaligned Indentation When Using Subqueries in Conditions

2 participants